<?php

class Ynbusinesspages_Model_Business extends Core_Model_Item_Abstract {

	protected $_type = 'ynbusinesspages_business';
    
    public function getCategories()
    {
    	$mapTbl = Engine_Api::_() -> getDbTable('categorymaps', 'ynbusinesspages');
    	$categoriesMaps = $mapTbl -> getCategoriesByBusinessId($this->getIdentity());
    	$categoryIds = array();
    	foreach($categoriesMaps as $map){
    		$categoryIds[] = $map -> category_id;
    	}
    	$categoryTbl = Engine_Api::_()->getItemTable('ynbusinesspages_category');
    	$select = $categoryTbl -> select() -> where("category_id IN (?)", $categoryIds);
    	return $categoryTbl -> fetchAll($select);
    }
    
}
